<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.server.web.JsVersionUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${projectName}</title>
<script type="text/javascript"
	src='<c:url value="/js/boot.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<script src="<c:url value='/js/jquery.ui.widget.js'></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>"></script>
<script src="<c:url value='/js/jquery.fileupload.js'></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>"></script>
<script src="<c:url value='/js/server/rqfCommon.js'></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>"></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>' />
<style type="text/css">
body {
	height: 100%;
}

.fieldTitle {
	width: 100px !important;
}

.mini-tabs-leftButton, .mini-tabs-rightButton {
	display: none;
}

.mini-tabs-scrollCt {
	border-top: 0;
}

.mini-tabs-bodys {
	padding: 0;
}

.headerpan {
	margin-left: 10px;
	font-size: 14px;
	font-weight: bold;
}
.org_img_style{
	width: 100%;
	height: 280px;
}
.orgImg {
	margin-left:auto; 
	margin-right:auto;
	width: 400px;
	height: 260px;
	/* border:1px solid #ccc; */
	background-size: 100%;
}
#uploadBtn {
	width: 75px;
	height: 20px;
	color: white;
	text-align: center;
	margin-left: auto;
	margin-right: auto;
	margin-top: 5px;
}
.cardStyle{
	background-size:400px 260px;
	width:400px;
	height: 260px;
	vertical-align: middle;
	margin-left:auto; 
	margin-right:auto;
}
.file {
	position: relative;
	display: inline-block;
	background: #1e519f;
	/*border: 1px solid #99D3F5;*/
	border-radius: 4px;
	/* padding: 4px 12px; */
	overflow: hidden;
	color: #1E88C7;
	text-decoration: none;
	text-indent: 0;
	line-height: 20px;
	cursor: pointer !important;
}
.file input {
	position: absolute;
	font-size: 100px;
	right: 0;
	top: 0;
	opacity: 0;
	cursor: pointer;
}

.file:hover {
	background: #ccc;
	text-decoration: none;
}
</style>
<script type="text/javascript">
	var stateData = [ {
		id : 0,
		text : "暂无招聘"
	}, {
		id : 1,
		text : "正在招聘"
	} ];
</script>
</head>
<body>
	<form id="dataForm">
		<div class="formContent">
			<input id="ParentNo" name="ParentNo" class="mini-hidden"
				style="width: 100%;" required="true" />
			<table class="formContentTable type1" id="type1">
				<span class="headerpan type1">基本信息</span>
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle">企业编号</td>
					<td class="fieldContent" colspan="3"><input id="OrgNo"
						name="OrgNo" class="mini-textbox" style="width: 100%;"
						required="true" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">企业名称</td>
					<td class="fieldContent" colspan="3"><input id="OrgName"
						name="OrgName" class="mini-textbox" style="width: 100%;"
						required="true" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">上级企业</td>
					<td class="fieldContent" colspan="3"><input name="ParentName"
						required="false" class="mini-combobox" id="ParentName"
						style="width: 100%;" textField="OrgName" valueField="OrgNo"
						url="<c:url value='/org/all'></c:url>" showNullItem="true"
						emptyText="无" allowInput="true" onValueChanged="" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">招聘状态</td>
					<td class="fieldContent"><input name="EmployState"
						id="EmployState" required="false" class="mini-combobox"
						style="width: 100%;" textField="text" valueField="id"
						data="stateData" showNullItem="false" allowInput="false"
						onvaluechanged="stateChaged" /></td>
					<td class="fieldTitle">预招聘时间</td>
					<td class="fieldContent"><input id="EmployTime"
						enabled="false" name="EmployTime" class="mini-datepicker"
						style="width: 100%;" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">招聘链接</td>
					<td class="fieldContent" colspan="3"><input id="EmployLink"
						name="EmployLink" class="mini-textbox" style="width: 100%;"
						required="false" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">企业介绍</td>
					<td class="fieldContent" colspan="3"><textarea id="Content"
							name="Content" style="width: 100%; height: 300px;"
							required="true" class="mini-textarea" emptyText="无"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">企业宣传图片</td>
					<td colspan="3" class="org_img_style"><div class="orgImg"
							style="border: 1px solid #ccc;"><a href="javascript:;">
							<img src="<c:url value='/share/images/company_1.png'></c:url>"
								id="imgUrlA" alt="" class="cardStyle" /></a>
						</div>
						<a href="javascript:;" class="file" id="uploadBtn">上传
							<input
							accept="image/png,image/bmp,image/jpeg,image/gif,image/jpg"
							name="fileA" type="file" id="fileIdA" />
					</a></td>
				</tr>
			</table>
		</div>
	</form>

	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		
		var rootPath = parent.getRootPath();
		var userName = parent.getUserName();
		var fileServer = parent.getFileServer();
		var action = parent.getAction();
		var id = parent.getId();
		var dataOri = null;
		
		var EmployState = mini.get("EmployState");
		var EmployTime = mini.get("EmployTime");
		var ParentNo = mini.get("ParentNo");
		var ParentName = mini.get("ParentName");

		if (action == "edit") {
			mini.get("OrgNo").disable();
			ParentName.disable();
		}
		if (parent.hideAtt) {
			parent.hideAtt();
		}
		var form = new mini.Form("dataForm");

		SetFormData();

		function SetFormData() {
			if (action == "new") {
				$('#uploadBtn').hide();
				var o = new Object();
				form.setData(o);
				dataOri = o;
				return;
			}
			var messageid = mini.loading("获取中...", "Loading");
			var urlBase = '<c:url value="/org/form/"></c:url>' + id;
			$.ajax({
				url : urlBase,
				type : "get",
				dataType : 'json',
				success : function(text) {
					if (!text) {
						return;
					}
					var o = mini.decode(text);
					if('0'==o.EmployState){
						EmployTime.setValue();
						EmployTime.disable();
					}else{
						EmployTime.enable();
					}
					var orgImg = o.OrgImg;
					if(orgImg){
						$("#imgUrlA").attr("src",fileServer + orgImg);
					}else{
						$("#imgUrlA").attr("src","<c:url value='/share/images/company_2.png'></c:url>");
					}
					form.setData(o);
					dataOri = o;
					parent.labelModel(form);
				},
				complete : function(XMLHttpRequest, textStatus) {
					mini.hideMessageBox(messageid);
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {

				}
			});
		}
		function packData() {
			return form;
		}
		function stateChaged() {
			var value = EmployState.getValue();
			if(value=='0'){
				EmployTime.setValue();
				EmployTime.disable();
			}else{
				EmployTime.enable();
			}
		}
		function parentChanged() {
			var value = ParentName.getValue();
			var object = value.split('serverSplit');
			ParentNo.setValue(object[0]);
		}
		$("#uploadBtn").click(function() {
			var orgId = dataOri.Id;
			$('#fileIdA').fileupload({
				dataType : 'html',//数据类型：json
				url : rootPath + 'attach/upload/fileA/无/OrgImg/'+orgId,//上传地址
				formData : {
					name : 'fileA'
				},
				add : function(e, data) {
					data.submit();
				},
				done : function(e, data) {
					var param = successDataTransform(data.result);
					if (param.isSuccess) {
						$("#imgUrlA").attr("src",fileServer + param.errorInfo);
					}
				}
			});
		});
	</script>
</body>
</html>